Embodiments of the present invention provide a method and apparatus for managing prefetching from a data buffer. In particular, the present invention provides a method and apparatus for preventing a read streamer from over-prefetching data from a data buffer.
When data is read from a buffer for use by another device, it is sometimes necessary to first prefetch the data into an intermediary buffer before writing the data to the device. An example is when a buffer has a latency time that cannot be tolerated by the device and an intermediary buffer is able to write the data to according to the requirements of the device.
One situation necessitating prefetching is a system that buffers the display data for a double-layer supertwist nematic (DSTN) display panel in system memory. A DSTN display panel is a passive-matrix LCD display and is available on many types of laptop computers. In a system with a DSTN display, display data is written to both one half of the display panel and to a buffer in memory, with the data written to the buffer later read out to refresh the display panel. The buffer contains up to one half a screen (referred to as a half frame) worth of display data, and is therefore referred to a half frame buffer. The architecture of some DSTN systems requires that the display data be buffered in system memory. In some systems, the display data in the half frame buffer cannot be written from the system memory directly to the DSTN display panel because the display panel requires that data be fed to it at a known and fixed delay. For this reason, the data is first prefetched by a read streamer. The read streamer prefetches the display from the half frame buffer, stores it in an intermediary read streamer buffer, and feeds it to the DSTN display.
Problems can occur if a read streamer prefetches from the buffer beyond the end of the display data that was written to the buffer. Not only does such unnecessary reading waste bandwidth, but the buffer into which the read streamer prefetches data is left with redundant data and must be flushed before prefetching new data. It is difficult to implement a mechanism to get rid of the redundant data when new data is written to the same locations in the buffer just after the data is prefetched. Moreover, it can be difficult to flush the read streamer buffer if it is written to and read from in different clock domains. The problem of over-prefetching from a buffer is a particular concern when the size of the buffer is not fixed in advance, for example where the data in the buffer is for a display panel and the application software can change the size of the area on the panel being used to display images.
Another problem that occurs in fetching data from the half frame buffer in some DSTN systems is that there may be an intolerable delay between the complete writing of a half frame of data to the half frame buffer and the time it takes for the read streamer to prefetch that data from the buffer and write it to the DSTN display panel. In particular, in these systems the read streamer buffer is unable to prefetch the data for the upper half of the DSTN display panel fast enough after the completion of the writing of that half frame of data to the half frame buffer. This problem typically does not occur when prefetching the data for the lower half of the DSTN display panel because the data can be prefetched during the vertical blanking period of the DSTN display panel, which is the period of time it takes for the display scanner to move from the lower right hand corner of the screen (where it just finished scanning the lower half panel) to the upper left hand corner (where it will begin scanning the upper half panel).
Based on the foregoing, there is a need for a method and apparatus that prevents overprefetching from a buffer. There is also a need to begin prefetching the data for the upper half frame from the half frame buffer in a DSTN system so as not to delay the scanning of the upper half frame.
Embodiments of the present invention provide a method and apparatus for preventing over-prefetching from a buffer. A data buffer address for a last item in a data set is received. The data from a data buffer is read into a read streamer buffer starting at a data buffer start address until the address of the last data item in the data set. In one embodiment of the invention, the address of the last data item is determined by a write steamer based on a signal indicating that the last item in the data set has been sent to the write streamer.